package cn.alm.mybatis01helloworld.service;

import cn.alm.mybatis01helloworld.entity.Emp;
import cn.alm.mybatis01helloworld.mapper.EmpMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpService {

    @Resource
    private EmpMapper empMapper;

    public PageInfo<Emp> getEmpList(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        // 紧跟startPage后的方法都会进行分页
        List<Emp> empList = empMapper.getEmpList();
        return new PageInfo<>(empList);
    }

}
